package io.renren.common.utils.docx;

import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap;

public class DocxTest {
    public static void main(String[] args) {

        WordprocessingMLPackage wPackage = null;
        try {
            wPackage = WordprocessingMLPackage.load(new FileInputStream("D:\\check.docx"));
            MainDocumentPart mainDocumentPart = wPackage.getMainDocumentPart();

            HashMap map=new HashMap();
            map.put("check","☑");

            mainDocumentPart.variableReplace(map);
            wPackage.save(new FileOutputStream("D:\\t.docx"));


        } catch (Docx4JException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }



    }
}
